|
|
@@ -76,19 +76,20 @@ module Agents
|
76
|
76
|
start = Time.now.to_f
|
77
|
77
|
measured_result = ping(url)
|
78
|
78
|
total_time = Time.now.to_f - start
|
|
79
|
+ puts measured_result
|
79
|
80
|
|
80
|
|
- current_status = measured_result.result ? measured_result.status.to_s : ''
|
|
81
|
+ current_status = measured_result ? measured_result.status.to_s : ''
|
81
|
82
|
return if options['changes_only'] == 'true' && current_status == memory['last_status'].to_s
|
82
|
83
|
|
83
|
84
|
payload = { 'url' => url, 'response_received' => false, 'elapsed_time' => total_time }
|
84
|
85
|
|
85
|
86
|
# Deal with failures
|
86
|
|
- if measured_result.result
|
87
|
|
- final_url = boolify(interpolated['disable_redirect_follow']) ? url : measured_result.result.to_hash[:url]
|
|
87
|
+ if measured_result
|
|
88
|
+ final_url = boolify(interpolated['disable_redirect_follow']) ? url : measured_result.to_hash[:url]
|
88
|
89
|
payload.merge!({ 'final_url' => final_url, 'redirected' => (url != final_url), 'response_received' => true, 'status' => current_status })
|
89
|
90
|
# Deal with headers
|
90
|
91
|
if local_headers.present?
|
91
|
|
- header_results = measured_result.result.headers.select {|header, value| local_headers.include?(header)}
|
|
92
|
+ header_results = measured_result.headers.select {|header, value| local_headers.include?(header)}
|
92
|
93
|
# Fill in headers that we wanted, but weren't returned
|
93
|
94
|
local_headers.each { |header| header_results[header] = nil unless header_results.has_key?(header) }
|
94
|
95
|
payload.merge!({ 'headers' => header_results })
|